package com.szeastroc.mapper.system;

import com.szeastroc.base.mapper.BaseMapper;
import com.szeastroc.bean.system.SystemUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface SystemUserMapper extends BaseMapper<SystemUser>{

    @Select("select * from t_system_user where username = #{userName}")
    public SystemUser selectByUserName(@Param("userName") String userName);

    @Select("SELECT u.id,u.name,u.username,u.mobile,u.email,u.status,u.create_time,r.name AS role_name FROM t_system_user u INNER JOIN `t_system_user_role` tsur  ON u.`id` = tsur.user_id INNER JOIN `t_system_role` r ON tsur.role_id = r.id")
    public List<SystemUser> selectUsers();

    @Update("update t_system_user set role_id = #{roleId} where id = #{userId}")
    public void updateUserRole(@Param("userId") Integer userId,@Param("roleId")Integer roleId);
}
